//
//  LSLossPerCentCompanyCell.m
//  LookScore
//
//  Created by wr on 2017/12/20.
//  Copyright © 2017年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSLossPerCentCompanyCell.h"
#import "LSExponentModel.h"
@interface LSLossPerCentCompanyCell()

@property(strong,nonatomic)UILabel *companyLab;

@end


@implementation LSLossPerCentCompanyCell
+(LSLossPerCentCompanyCell *)LossPerCentCompanyCellByTableView:(UITableView *)tableView{
    LSLossPerCentCompanyCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSLossPerCentCompanyCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
   
    UILabel *companyLab=[[UILabel alloc]init];
    companyLab.font=LSFontSize13;
    companyLab.textColor=[UIColor blackColor];
    [self.contentView addSubview:companyLab];
    self.companyLab=companyLab;
    companyLab.sd_layout.leftEqualToView(self.contentView).offset(LSSpaceLeftWidth1).centerYEqualToView(self.contentView).widthRatioToView(self.contentView,.6).heightRatioToView(self.contentView, 1);
   
    
    UIButton *selectedBu=[UIButton new];
    [selectedBu setBackgroundImage:[UIImage imageNamed:@"HomeUnChoose"] forState:UIControlStateNormal];
    [selectedBu setBackgroundImage:[UIImage imageNamed:@"HomeChoose"] forState:UIControlStateSelected];
    [selectedBu addTarget:self action:@selector(selectedEvent:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:selectedBu];
    self.selectedBu=selectedBu;
    selectedBu.sd_layout.leftSpaceToView(companyLab, 10). rightEqualToView(self.contentView).offset(-LSSpaceLeftWidth1).heightIs(14).widthEqualToHeight().centerYEqualToView(self.contentView);
    
    
    UIView *lineView=[[UIView alloc]init];
    lineView.backgroundColor=LSBackGroundColor;
    [self.contentView addSubview:lineView];
    lineView.sd_layout.leftEqualToView(self.contentView).rightEqualToView(self.contentView).bottomEqualToView(self.contentView).heightIs(1);
    

}

- (void)setModel:(CompanyList *)model{
    
    _model = model;
    self.companyLab.text = model.CompanyName;
    _selectedBu.selected = model.isSelected;
    
}


#pragma mark 🔥 Event
-(void)selectedEvent:(UIButton *)sender{
    sender.selected = !sender.selected;
    
    self.block(sender,self.indexPath);
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
